/*******************************************************************************
System Interrupts File
File Name:
system_interrupt.c
Summary:
Raw ISR definitions.
Description:
This file contains a definitions of the raw ISRs required to support the
interrupt sub-system.
Summary:
This file contains source code for the interrupt vector functions in the
system.
Description:
This file contains source code for the interrupt vector functions in the
system. It implements the system and part specific vector "stub" functions
from which the individual "Tasks" functions are called for any modules
executing interrupt-driven in the MPLAB Harmony system.
Remarks:
This file requires access to the systemObjects global data structure that
contains the object handles to all MPLAB Harmony module objects executing
interrupt-driven in the system. These handles are passed into the individual
module "Tasks" functions to identify the instance of the module to maintain.
*******************************************************************************/
// DOM-IGNORE-BEGIN
/*******************************************************************************
Copyright (c) 2011-2014 released Microchip Technology Inc. All rights reserved.
Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).
You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.
SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*******************************************************************************/
// DOM-IGNORE-END
// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************
#include "system/common/sys_common.h"
#include "app.h"
#include "system_definitions.h"
short int angleValue = 0;
extern short int sinValue[360]; //sinテーブル値
// *****************************************************************************
// *****************************************************************************
// Section: System Interrupt Vector Functions
// *****************************************************************************
// *****************************************************************************
void __ISR(_TIMER_1_VECTOR, ipl1AUTO) IntHandlerDrvTmrInstance0(void)
{
// PLIB_TMR_Period16BitSet(TMR_ID_1,25000); //5 nsec x2 x 25000 x 8 = 10000nsec = 1000μsec = 2msec
//SPI4の場合
LATFbits.LATF2 = 0; //MCP4922 CS = 0
//送信データ送信
PLIB_SPI_BufferWrite16bit(SPI_ID_4,(short int)(sinValue[angleValue] | 0b0001000000000000)); //送信データ送信
// SPI4BUF = (short int)(sinValue[angleValue] | 0b0001000000000000); //送信データ送信
//MP4922 制御コマンド
//VoutAにゲイン2で出力
//MCP4922への書き込みコマンド
//bit15(書き込みレジスタ選択) 1:VoutB 0:VoutA
//bit14(予備)
//bit13(出力ゲイン選択) 1:1倍 0:2倍
//bit12(出力オフ制御) 1:出力ON 0:出力OFF
//bit11?bit0 データ MSBから順次送信される
while(PLIB_SPI_TransmitBufferIsFull(SPI_ID_4)); //SPI4SRレジスタへの書込み完了
// while(SPI4STATbits.SPITBF); //: SPI Transmit Buffer Full Status bit //SPI4SRレジスタへの書込み完了
delay_us(20); //MCP4922の処理待ち
angleValue++;
if(angleValue >= 360)angleValue = 0;
LATFbits.LATF2 = 1; //MCP4922 CS = 1;
PLIB_INT_SourceFlagClear(INT_ID_0,INT_SOURCE_TIMER_1);
}
/*******************************************************************************
End of File
*/